
********************************************************************************
/* 	
	Author:			Zeynep Somer-Topcu
	Purpose:		Cleaning and analyzing the experiment data for Study 2
*/
********************************************************************************
clear all 
set more off

import delimited using "Distortion_Qualtrics.csv", varnames(1) clear


** Data Preparation/ Cleaning for Analysis **

rename q2 q2_pid

rename q4 q4_leftright_self
replace q4_leftright_self="1" if q4_leftright_self=="1- Left"
replace q4_leftright_self="10" if q4_leftright_self=="10- Right"
destring q4_leftright_self, replace
label variable q4_leftright_self "left-right self"

rename q3 q3_strength_pid
replace q3_strength_pid="0" if q3_strength_pid=="Not very strongly"
replace q3_strength_pid="1" if q3_strength_pid=="Fairly strongly"
replace q3_strength_pid="2" if q3_strength_pid=="Very strongly"
destring q3_strength_pid, replace
label define q3_strength_pid 0 "Not very strongly" 1 "Fairly strongly" 2 "Very strongly"

rename q5 q5_environment_self
replace q5_environment_self="1" if q5_environment_self=="1- I strongly support protection of the environment, even at the cost to the business sector"
replace q5_environment_self="10" if q5_environment_self=="10- I strongly support the interests of business sector even at the cost of damage to the environment"
destring q5_environment_self, replace
label variable q5_environment_self "environment self 1-pro environment"

rename q6 q6_immigration_self
replace q6_immigration_self="1" if q6_immigration_self=="1- I strongly support pro-immigration policies"
replace q6_immigration_self="10" if q6_immigration_self=="10- I strongly support policies that restrict immigration"
destring q6_immigration_self, replace
label variable q6_immigration_self "immigration self 1- pro immigration"

rename q7 q7_domestic_security_self
replace q7_domestic_security_self="1" if q7_domestic_security_self=="1- I strongly support humanitarian considerations even at the expense of national security"
replace q7_domestic_security_self="10" if q7_domestic_security_self=="10- I strongly support national security even at the expense of humanitarian considerations"
destring q7_domestic_security_self, replace
label variable q7_domestic_security_self "humanitarian- national security self scale"

rename q8 q8_ethnicity
replace q8_ethnicity="1" if q8_ethnicity=="White" 
replace q8_ethnicity="2" if q8_ethnicity=="Mixed/multiple ethnic groups" 
replace q8_ethnicity="3" if q8_ethnicity=="Asian/ Asian British" 
replace q8_ethnicity="4" if q8_ethnicity=="Black/ African/ Caribbean/ Black British" 
replace q8_ethnicity="5" if q8_ethnicity=="Other Ethnic Group" 
destring q8_ethnicity, replace
label define q8_ethnicity 1 "White" 2 "Mixed/multiple ethnic groups" 3 "Asian/ Asian British" 4 "Black/ African/ Caribbean/ Black British" 5 "Other Ethnic Group" 
label values q8_ethnicity q8_ethnicity

destring q9_1, replace
rename q9_1 q9_birthyear

gen age=2019-q9_birthyear

rename q10 q10_gender
replace q10="1" if q10=="Female"
replace q10="0" if q10=="Male"
destring q10, replace
label variable q10 "1: female, 0: male"

rename q11 q11_education_status

replace q11_3="22" if q11_3=="`22"
replace q11_3="26" if q11_3=="26 year"
replace q11_3="23" if q11_3=="23 years"
replace q11_3="18" if q11_3==";18"
replace q11_3="16" if q11_3=="16/17 "
replace q11_3="17" if q11_3=="17Â£"
replace q11_3="." if q11_3=="BA"
replace q11_3="." if q11_3=="College"
replace q11_3="." if q11_3=="Finance"
replace q11_3="." if q11_3=="PhD"
replace q11_3="." if q11_3=="University level (degree)"
replace q11_3="." if q11_3=="still at University"
replace q11_3="." if q11_3=="I'm a postgraduate student currently"

destring q11_3, replace
replace q11_3=. if q11_3==1

rename q11_3 q11_age_education

gen age_educ_completed= q11_age_education if q11_age_education<100
replace age_educ_completed= age if q11_education_status=="I am still in school"
replace age_educ_completed= 2019-q11_age_education if q11_age_education>1000 & q11_age_education!=.
replace age_educ_completed=0 if q11_education_status=="I received no formal education"


gen q12_income=q12
replace q12_income="1" if q12_income=="under Â£10,000 per year"
replace q12_income="2" if q12_income=="Â£10,000 to Â£29,999 per year"
replace q12_income="3" if q12_income=="Â£30,000 to Â£49,999 per year"
replace q12_income="4" if q12_income=="Â£50,000 to Â£69,999 per year"
replace q12_income="5" if q12_income=="Â£70,000 to Â£99,999 per year"
replace q12_income="6" if q12_income=="Â£100,000 to Â£149,999 per year"
replace q12_income="7" if q12_income=="Â£150,000 and over"
destring q12_income, replace
label define q12_income 1 "under £10,000 per year" 2 "£10,000 to £29,999 per year" 3 "£30,000 to £49,999 per year" 4 "£50,000 to £69,999 per year" 5 "£70,000 to £99,999 per year" 6 "£100,000 to £149,999 per year" 7 "£150,000 and over"
label values q12_income q12_income

gen TV_watching= q14_1
replace TV_="0" if TV_=="None, no time at all"
replace TV_="1" if TV_=="Less than 1 hour"
replace TV_="2" if TV_=="1 to 5 hours"
replace TV_="3" if TV_=="More than 5 hours"
destring TV_, replace

gen Newspaper= q14_2
replace Newsp="0" if Newsp=="None, no time at all"
replace Newsp="1" if Newsp=="Less than 1 hour"
replace Newsp="2" if Newsp=="1 to 5 hours"
replace Newsp="3" if Newsp=="More than 5 hours"
destring Newsp, replace

gen Radio= q14_3
replace Radio="0" if Radio=="None, no time at all"
replace Radio="1" if Radio=="Less than 1 hour"
replace Radio="2" if Radio=="1 to 5 hours"
replace Radio="3" if Radio=="More than 5 hours"
destring Radio, replace

gen Internet= q14_4
replace Internet="0" if Internet=="None, no time at all"
replace Internet="1" if Internet=="Less than 1 hour"
replace Internet="2" if Internet=="1 to 5 hours"
replace Internet="3" if Internet=="More than 5 hours"
destring Internet, replace

gen other_people= q14_5
replace other_people="0" if other_people=="None, no time at all"
replace other_people="1" if other_people=="Less than 1 hour"
replace other_people="2" if other_people=="1 to 5 hours"
replace other_people="3" if other_people=="More than 5 hours"
destring other_people, replace

gen media_attention= TV_watching+Newspaper+Radio+Internet+other_people

*q13_1= corbyn = "Leader of the Opposition"
*q13_2= barclay = "Brexit Secretary"
*q13_3= swinson = "Leader of teh Liberal Democrats"
*q13_4= bercow = "Speaker of teh House of Commons"
*q13_5= javid= "Chancellor of the Exchequer"
*for all= 6= don't know

gen knowledge1=1 if q13_1=="Leader of the Opposition"
replace knowledge1=0 if knowledge1!=1
gen knowledge2=1 if q13_2=="Brexit Secretary"
replace knowledge2=0 if knowledge2!=1
gen knowledge3=1 if q13_3=="Leader of the Liberal Democrats"
replace knowledge3=0 if knowledge3!=1
gen knowledge4=1 if q13_4=="Speaker of the House of Commons"
replace knowledge4=0 if knowledge4!=1
gen knowledge5=1 if q13_5=="Chancellor of the Exchequer"
replace knowledge5=0 if knowledge5!=1

gen allknowledge= knowledge1 + knowledge2 + knowledge3 + knowledge4 + knowledge5
tab allknowledge

gen knowledge= (knowledge1 + knowledge2 + knowledge3 + knowledge4 + knowledge5)/5


 destring q75_pagesubmit, replace
 
 bysort allknowledge: sum q75_pagesubmit, detail
 
gen q15_political_interest=q15
replace q15_political_interest="0" if q15=="Not at all interested"
replace q15_political_interest="1" if q15=="Not very interested"
replace q15_political_interest="2" if q15=="Fairly interested"
replace q15_political_interest="3" if q15=="Very interested"
destring q15_political_interest, replace
label define q15_political_interest 0 "Not at all interested" 1 "Not very interested" 2 "Fairly interested" 3 "Very interested" 
label values q15_political_interest q15_political_interest

gen q52_turnout=q52
replace q52_turnout="0" if q52=="Very unlikely that I would vote"
replace q52_turnout="1" if q52=="Fairly unlikely"
replace q52_turnout="2" if q52=="Neither likely nor unlikely"
replace q52_turnout="3" if q52=="Fairly likely"
replace q52_turnout="4" if q52=="Very likely that I would vote"
destring q52_turnout, replace

rename q53 q53_votechoice
replace q53_votechoice="1" if q53_votechoice=="Conservative"
replace q53_votechoice="2" if q53_votechoice=="Labour"
replace q53_votechoice="3" if q53_votechoice=="Liberal Democrat"
replace q53_votechoice="4" if q53_votechoice=="Scottish National Party (SNP)"
replace q53_votechoice="5" if q53_votechoice=="United Kingdom Independence Party (UKIP)"
replace q53_votechoice="6" if q53_votechoice=="Brexit Party"
replace q53_votechoice="7" if q53_votechoice=="Green Party"
replace q53_votechoice="8" if q53_votechoice=="British National Party (BNP)"
replace q53_votechoice="9" if q53_votechoice=="Other"
replace q53_votechoice="10" if q53_votechoice=="Would not vote"
destring q53_votechoice, replace
label define votechoice 1 "Conservative" 2 "Labour" 3 "LibDem" 4 "SNP"  5  "UKIP" 6 "Brexit" 7 "Green" 8 "BNP" 9 "Other" 10 "Wouldn't vote"
label values q53_votechoice votechoice

gen vote_conservative=1 if q53_votechoice==1
replace vote_conservative=0 if q53_votechoice!=1 & q53_votechoice!=.

gen vote_labour=1 if q53_votechoice==2
replace vote_labour=0 if q53_votechoice!=2 & q53_votechoice!=.


gen q54_like_labour=q54
replace q54_like_labour="0" if q54=="0   Strongly dislike"
replace q54_like_labour="10" if q54=="10 Strongly like"
destring q54_like_labour, replace

gen q55_like_cons=q55
replace q55_like_cons="0" if q55=="0   Strongly dislike"
replace q55_like_cons="10" if q55=="10 Strongly like"
destring q55_like_cons, replace


gen q56_confidence_cons=q56
replace q56_confidence_cons="0" if q56=="None at all"
replace q56_confidence_cons="1" if q56=="Not very much"
replace q56_confidence_cons="2" if q56=="Quite a lot"
replace q56_confidence_cons="3" if q56=="A great deal"
destring q56_confidence_cons, replace
label define confidence 3 "A great deal" 2 "Quite a lot" 1 "Not very much" 0 "None at all"  
label values q56_confidence_cons confidence

gen q57_confidence_lab=q57
replace q57_confidence_lab="0" if q57=="None at all"
replace q57_confidence_lab="1" if q57=="Not very much"
replace q57_confidence_lab="2" if q57=="Quite a lot"
replace q57_confidence_lab="3" if q57=="A great deal"
destring q57_confidence_lab, replace
label values q57_confidence_lab confidence


gen q58_env_personal_imp=q58
replace q58_env_personal_imp="0" if q58=="Not at all"
replace q58_env_personal_imp="1" if q58=="A little"
replace q58_env_personal_imp="2" if q58=="A moderate amount"
replace q58_env_personal_imp="3" if q58=="A lot"
replace q58_env_personal_imp="4" if q58=="A great deal"
destring q58_env_personal_imp, replace
label define importance 4 "A great deal" 3 "A lot" 2 "A moderate amount" 1 "A little"  0  "Not at all" 
label values q58_env_personal_imp importance


gen q59_env_general_imp=q59
replace q59_env_general_imp="0" if q59=="Not at all"
replace q59_env_general_imp="1" if q59=="A little"
replace q59_env_general_imp="2" if q59=="A moderate amount"
replace q59_env_general_imp="3" if q59=="A lot"
replace q59_env_general_imp="4" if q59=="A great deal"
destring q59_env_general_imp, replace
label values q59_env_general_imp importance

gen q60_imm_personal_imp=q60
replace q60_imm_personal_imp="0" if q60=="Not at all"
replace q60_imm_personal_imp="1" if q60=="A little"
replace q60_imm_personal_imp="2" if q60=="A moderate amount"
replace q60_imm_personal_imp="3" if q60=="A lot"
replace q60_imm_personal_imp="4" if q60=="A great deal"
destring q60_imm_personal_imp, replace
label values q60_imm_personal_imp importance

gen q61_imm_general_imp=q61
replace q61_imm_general_imp="0" if q61=="Not at all"
replace q61_imm_general_imp="1" if q61=="A little"
replace q61_imm_general_imp="2" if q61=="A moderate amount"
replace q61_imm_general_imp="3" if q61=="A lot"
replace q61_imm_general_imp="4" if q61=="A great deal"
destring q61_imm_general_imp, replace
label values q61_imm_general_imp importance

drop if q3_strength==. & q4_leftright==. & q5_environment==. & q6_immigration==. & q7_domestic==. & TV_watching==. & Newspaper==. & Radio==. & Internet==. & other_people==. & q15_political_interest==. & q52_turnout==. & q54_like_labour==. & q55_like_cons==. & q56_conf==. & q57_conf==. & q58_env==. & q59_env==. & q60_imm==. & q61_imm==. 

drop q1 q73  q12 q14_1 q14_2 q14_3 q14_4 q14_5 q13_1 q13_2 q13_3 q13_4 q13_5 q15 q75_firstclick q75_lastclick q75_clickcount q52 q53 q54 q54 q55 q56 q57 q58 q59 q60 q60 q61 


replace q16="1" if q16=="1 Strongly supports protection of the environment, even at the cost to the business sector"
replace q16="10" if q16=="10 Strongly supports the interests of the business sector even at the cost of damage to the environment"
destring q16, gen(Cons_env_self)

gen Cons_env_self_cert=q17
replace Cons_env_self_cert="0" if q17=="Not at all certain"
replace Cons_env_self_cert="1" if q17=="Somewhat Certain"
replace Cons_env_self_cert="2" if q17=="Very certain"
destring Cons_env_self_cert, replace
label define certainty 0 "Not at all certain" 1 "Somewhat certain" 2 "Very certain"
label values Cons_env_self_cert certainty

replace q19="1" if q19=="1 Strongly supports protection of the environment, even at the cost to the business sector"
replace q19="10" if q19=="10  Strongly supports the interests of the business sector even at the cost of damage to the environment"
destring q19, gen(Cons_env_distorted)

gen Cons_env_distorted_cert=q20
replace Cons_env_distorted_cert="0" if q20=="Not at all certain"
replace Cons_env_distorted_cert="1" if q20=="Somewhat Certain"
replace Cons_env_distorted_cert="2" if q20=="Very certain"
destring Cons_env_distorted_cert, replace
label values Cons_env_distorted_cert certainty

replace q22="1" if q22=="1 Strongly supports protection of the environment, even at the cost to the business sector"
replace q22="10" if q22=="10 Strongly supports the interests of the business sector even at the cost of damage to the environment"
destring q22, gen(Cons_env_baseline)

gen Cons_env_baseline_cert=q23
replace Cons_env_baseline_cert="0" if q23=="Not at all certain"
replace Cons_env_baseline_cert="1" if q23=="Somewhat Certain"
replace Cons_env_baseline_cert="2" if q23=="Very certain"
destring Cons_env_baseline_cert, replace
label values Cons_env_baseline_cert certainty


gen env_cons_position=Cons_env_self
replace env_cons_position=Cons_env_distorted if env_cons_position==.
replace env_cons_position=Cons_env_baseline if env_cons_position==.

gen env_cons_certainty= Cons_env_self_cert
replace env_cons_certainty=Cons_env_distorted_cert if env_cons_certainty==.
replace env_cons_certainty=Cons_env_baseline_cert if env_cons_certainty==.

replace q25="1" if q25=="1 Strongly supports protection of the environment, even at the cost to the business sector"
replace q25="10" if q25=="10  Strongly supports the interests of the business sector even at the cost of damage to the environment"
destring q25, gen(Lab_env_self)

gen Lab_env_self_cert=q26
replace Lab_env_self_cert="0" if q26=="Not at all certain"
replace Lab_env_self_cert="1" if q26=="Somewhat Certain"
replace Lab_env_self_cert="2" if q26=="Very certain"
destring Lab_env_self_cert, replace
label values Lab_env_self_cert certainty

replace q28="1" if q28=="1 Strongly supports protection of the environment, even at the cost to the business sector"
replace q28="10" if q28=="10 Strongly supports the interests of the business sector even at the cost of damage to the environment"
destring q28, gen(Lab_env_distorted)

gen Lab_env_distorted_cert=q29
replace Lab_env_distorted_cert="0" if q29=="Not at all certain"
replace Lab_env_distorted_cert="1" if q29=="Somewhat Certain"
replace Lab_env_distorted_cert="2" if q29=="Very certain"
destring Lab_env_distorted_cert, replace
label values Lab_env_distorted_cert certainty

replace q31="1" if q31=="1 Strongly supports protection of the environment, even at the cost to the business sector"
replace q31="10" if q31=="10 Strongly supports the interests of the business sector even at the cost of damage to the environment"
destring q31, gen(Lab_env_baseline)

gen Lab_env_baseline_cert=q32
replace Lab_env_baseline_cert="0" if q32=="Not at all certain"
replace Lab_env_baseline_cert="1" if q32=="Somewhat Certain"
replace Lab_env_baseline_cert="2" if q32=="Very certain"
destring Lab_env_baseline_cert, replace
label values Lab_env_baseline_cert certainty

gen env_lab_position=Lab_env_self
replace env_lab_position=Lab_env_distorted if env_lab_position==.
replace env_lab_position=Lab_env_baseline if env_lab_position==.

gen env_lab_certainty= Lab_env_self_cert
replace env_lab_certainty=Lab_env_distorted_cert if env_lab_certainty==.
replace env_lab_certainty=Lab_env_baseline_cert if env_lab_certainty==.


replace q34="1" if q34=="1 Strongly supports pro-immigration policies"
replace q34="10" if q34=="10 Strongly supports policies that restrict immigration"
destring q34, gen(Cons_imm_self)

gen Cons_imm_self_cert=q35
replace Cons_imm_self_cert="0" if q35=="Not at all certain"
replace Cons_imm_self_cert="1" if q35=="Somewhat Certain"
replace Cons_imm_self_cert="2" if q35=="Very certain"
destring Cons_imm_self_cert, replace
label values Cons_imm_self_cert certainty

replace q37="1" if q37=="1 Strongly supports pro-immigration policies"
replace q37="10" if q37=="10 Strongly supports policies that restrict immigration"
destring q37, gen(Cons_imm_distorted)

gen Cons_imm_distorted_cert=q38
replace Cons_imm_distorted_cert="0" if q38=="Not at all certain"
replace Cons_imm_distorted_cert="1" if q38=="Somewhat Certain"
replace Cons_imm_distorted_cert="2" if q38=="Very certain"
destring Cons_imm_distorted_cert, replace
label values Cons_imm_distorted_cert certainty

replace q40="1" if q40=="1 Strongly supports pro-immigration policies"
replace q40="10" if q40=="10 Strongly supports policies that restrict immigration"
destring q40, gen(Cons_imm_baseline)

gen Cons_imm_baseline_cert=q41
replace Cons_imm_baseline_cert="0" if q41=="Not at all certain"
replace Cons_imm_baseline_cert="1" if q41=="Somewhat Certain"
replace Cons_imm_baseline_cert="2" if q41=="Very certain"
destring Cons_imm_baseline_cert, replace
label values Cons_imm_baseline_cert certainty

gen imm_cons_position= Cons_imm_self
replace imm_cons_position=Cons_imm_distorted if imm_cons_position==.
replace imm_cons_position=Cons_imm_baseline if imm_cons_position==.

gen imm_cons_certainty= Cons_imm_self_cert
replace imm_cons_certainty=Cons_imm_distorted_cert if imm_cons_certainty==.
replace imm_cons_certainty=Cons_imm_baseline_cert if imm_cons_certainty==.


replace q43="1" if q43=="1 Strongly supports pro-immigration policies"
replace q43="10" if q43=="10 Strongly supports policies that restrict immigration"
destring q43, gen(Lab_imm_self)

gen Lab_imm_self_cert=q44
replace Lab_imm_self_cert="0" if q44=="Not at all certain"
replace Lab_imm_self_cert="1" if q44=="Somewhat Certain"
replace Lab_imm_self_cert="2" if q44=="Very certain"
destring Lab_imm_self_cert, replace
label values Lab_imm_self_cert certainty

replace q46="1" if q46=="1 Strongly supports pro-immigration policies"
replace q46="10" if q46=="10 Strongly supports policies that restrict immigration"
destring q46, gen(Lab_imm_distorted)

gen Lab_imm_distorted_cert=q47
replace Lab_imm_distorted_cert="0" if q47=="Not at all certain"
replace Lab_imm_distorted_cert="1" if q47=="Somewhat Certain"
replace Lab_imm_distorted_cert="2" if q47=="Very certain"
destring Lab_imm_distorted_cert, replace
label values Lab_imm_distorted_cert certainty

replace q49="1" if q49=="1 Strongly supports pro-immigration policies"
replace q49="10" if q49=="10 Strongly supports policies that restrict immigration"
destring q49, gen(Lab_imm_baseline)

gen Lab_imm_baseline_cert=q50
replace Lab_imm_baseline_cert="0" if q50=="Not at all certain"
replace Lab_imm_baseline_cert="1" if q50=="Somewhat Certain"
replace Lab_imm_baseline_cert="2" if q50=="Very certain"
destring Lab_imm_baseline_cert, replace
label values Lab_imm_baseline_cert certainty

gen imm_lab_position=Lab_imm_self
replace imm_lab_position=Lab_imm_distorted if imm_lab_position==.
replace imm_lab_position=Lab_imm_baseline if imm_lab_position==.

gen imm_lab_certainty= Lab_imm_self_cert
replace imm_lab_certainty=Lab_imm_distorted_cert if imm_lab_certainty==.
replace imm_lab_certainty=Lab_imm_baseline_cert if imm_lab_certainty==.


drop q17 q18_firstclick q18_lastclick q18_clickcount q19 q20 q21_firstclick q21_lastclick q21_clickcount q22 q23 q24_firstclick q24_lastclick q24_clickcount q25 q26 q27_firstclick q27_lastclick q27_clickcount q28 q29 q30_firstclick q30_lastclick q30_clickcount q31 q32 q33_firstclick q33_lastclick q33_clickcount q34 q35 q36_firstclick q36_lastclick q36_clickcount q37 q38 q39_firstclick q39_lastclick q39_clickcount q40 q41 q42_firstclick q42_lastclick q42_clickcount q43 q44 q45_firstclick q45_lastclick q45_clickcount q46 q47 q48_firstclick q48_lastclick q48_clickcount q49 q50 q51_firstclick q51_lastclick q51_clickcount


gen partyid=1 if q2_pid=="Conservative Party"
replace partyid=2 if q2_pid=="Labour Party"
replace partyid=4 if partyid==.
replace partyid=3 if q2_pid=="None"
* 1: Conservative, 2=Labour, 3= None, 4= all others


destring q18_pagesubmit, replace
destring q21_pagesubmit, replace
destring q24_pagesubmit, replace
destring q27_pagesubmit, replace
destring q30_pagesubmit, replace
destring q33_pagesubmit, replace
destring q36_pagesubmit, replace
destring q39_pagesubmit, replace
destring q42_pagesubmit, replace
destring q45_pagesubmit, replace
destring q48_pagesubmit, replace
destring q51_pagesubmit, replace


gen conservative=1 if partyid==1
replace conservative=0 if partyid!=1 

gen labour=1 if partyid==2
replace labour=0 if partyid!=2 

gen independent=1 if partyid==3
replace independent=0 if partyid!=3

gen third_party=1 if partyid==4
replace third_party=0 if partyid!=4

gen white=1 if q8==1
replace white=0 if q8!=1

* generating dummy variables for each respondent for their experimental condition

gen C_A=1 if Cons_env_self!=.
replace C_A=0 if Cons_env_self==.
gen C_B=1 if Cons_env_distorted!=.
replace C_B=0 if Cons_env_distorted==.
gen C_C=1 if Cons_env_baseline!=.
replace C_C=0 if Cons_env_baseline==.
gen L_A=1 if Lab_env_self!=.
replace L_A=0 if Lab_env_self==.
gen L_B=1 if Lab_env_distorted!=. 
replace L_B=0 if Lab_env_distorted==.
gen L_C=1 if Lab_env_baseline!=.
replace L_C=0 if Lab_env_baseline==.
gen C_D=1 if Cons_imm_self!=.
replace C_D=0 if Cons_imm_self==.
gen C_E=1 if Cons_imm_distorted!=.
replace C_E=0 if Cons_imm_distorted==.
gen C_F=1 if Cons_imm_baseline!=. 
replace C_F=0 if Cons_imm_baseline==.
gen L_D=1 if Lab_imm_self!=.
replace L_D=0 if Lab_imm_self==.
gen L_E=1 if Lab_imm_distorted!=.
replace L_E=0 if Lab_imm_distorted==.
gen L_F=1 if Lab_imm_baseline!=.
replace L_F=0 if Lab_imm_baseline==.

gen cons_env=1 if C_A==1 | C_B==1 | C_C==1
replace cons_env=0 if C_D==1 | C_E==1 | C_F==1 | L_A==1 | L_B==1 | L_C==1 | L_D==1 | L_E==1 | L_F==1
gen con_imm= 1 if C_D==1 | C_E==1 | C_F==1 
replace con_imm=0 if C_A==1 | C_B==1 | C_C==1 | L_A==1 | L_B==1 | L_C==1 | L_D==1 | L_E==1 | L_F==1
gen lab_env=1 if L_A==1 | L_B==1 | L_C==1 
replace lab_env=0 if C_A==1 | C_B==1 | C_C==1 | C_D==1 | C_E==1 | C_F==1  | L_D==1 | L_E==1 | L_F==1
gen lab_imm=1 if L_D==1 | L_E==1 | L_F==1
replace lab_imm=0 if C_A==1 | C_B==1 | C_C==1 | C_D==1 | C_E==1 | C_F==1  | L_A==1 | L_B==1 | L_C==1


gen conserv_exp_takers=1 if C_A==1 | C_B==1 | C_C==1 | C_D==1 | C_E==1 | C_F==1
replace conserv_exp_takers=0 if L_A==1 | L_B==1 | L_C==1 | L_D==1 | L_E==1 | L_F==1
gen labour_exp_takers=1 if L_A==1 | L_B==1 | L_C==1 | L_D==1 | L_E==1 | L_F==1 
replace labour_exp_takers=0 if C_A==1 | C_B==1 | C_C==1 | C_D==1 | C_E==1 | C_F==1

gen strong_pid= 1 if q3_strength==2 | q3_strength_pid==1
replace strong_pid=0 if q3_strength==0

* generating the outlier variable for those outside one standard deviation of the mean response time
sum q18_pagesubmit if q18<400, detail
gen outlier=1 if q18<14.7061 | (q18>84.589 & q18!=.)

sum q21 if q21<600, detail
replace outlier=1 if q21<17.033 | (q21>112.5915 & q21!=.)

sum q27 if q27<600, detail
replace outlier=1 if q27<22.383 | (q27>88.01952 & q27!=.)

sum q30 if q30<400, detail
replace outlier=1 if q30<22.71739 | (q30>121.27539 & q30!=.)

sum q36 if q36<400, detail
replace outlier=1 if q36<17.51846 | (q36>83.4289 & q36!=.)

sum q39 if q39<400, detail
replace outlier=1 if q39<24.52721 | (q39>105.73535 & q39!=.)

sum q45 if q45<300, detail
replace outlier=1 if q45<20.04036 | (q45>78.49568 & q45!=.)

sum q48 if q48<400, detail
replace outlier=1 if q48<21.53699 | (q48>109.85851 & q48!=.)

save distortion_experiment_data_cleaned.dta, replace


*** Balance Tests (Online Appendix 2.2)

* Figure OA.2.2.1: All Respondents

reg q10_gender C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store gender
reg age C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1  
est store age
reg age_educ_completed C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store educ
reg q3_strength_pid C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store strength_pid
reg q4_leftright C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store leftright
reg q5_environment C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store environment
reg q6_immigration C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store immigration
reg q7_domestic_security C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store domestic_sec
reg q12_income C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store income
reg allknowledge  C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store allknow
reg knowledge  C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
reg media_attention C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store media_att
reg TV_ C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
reg Newsp C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
reg Radio C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
reg Internet C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
reg other_people C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
reg q15_political_interest C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store interest

logit white C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store white
logit conservative C_A C_B C_D C_E L_A L_B L_D if C_C!=1 & C_F!=1 & L_C!=1 & L_F!=1 
est store conservative

coefplot gender, bylabel(Female) ||age, bylabel (Age)|| educ, bylabel (Education)|| strength_pid, bylabel (PID strength)||leftright, bylabel (Left-Right)||environment, bylabel (Environment)||immigration, bylabel (Immigration)||income, bylabel (Income)||allknow, bylabel (Knowledge)||media_att, bylabel (Media Attention)||interest, bylabel (Pol Interest)|| white, bylabel (Race)||, drop(_cons) xline(0)

* separately for conservative and labour experiments' takers

*Figure OA.2.2.2: Conservative Party Supporters

reg q10_gender C_A C_B C_D if conserv_exp_takers==1
est store gender_cons
reg age  C_A C_B  C_D  if conserv_exp_takers==1
est store age_cons
reg age_educ_completed C_A C_B  C_D  if conserv_exp_takers==1
est store educ_cons
reg q3_strength_pid C_A C_B  C_D  if conserv_exp_takers==1
est store strength_cons
reg q4_leftright C_A C_B  C_D  if conserv_exp_takers==1
est store leftright_cons
reg q5_environment C_A C_B  C_D  if conserv_exp_takers==1
est store environ_cons
reg q6_immigration C_A C_B  C_D  if conserv_exp_takers==1
est store immig_cons
reg q7_domestic_security C_A C_B  C_D  if conserv_exp_takers==1
reg q12_income C_A C_B  C_D  if conserv_exp_takers==1
est store income_cons
reg allknowledge C_A C_B  C_D  if conserv_exp_takers==1
est store know_cons
reg knowledge C_A C_B  C_D  if conserv_exp_takers==1
reg media_attention C_A C_B  C_D  if conserv_exp_takers==1
est store media_cons
reg TV_  C_A C_B  C_D  if conserv_exp_takers==1
reg Newsp  C_A C_B  C_D  if conserv_exp_takers==1
reg Radio  C_A C_B  C_D  if conserv_exp_takers==1
reg Internet  C_A C_B  C_D  if conserv_exp_takers==1
reg other_people C_A C_B  C_D  if conserv_exp_takers==1
reg q15_political_interest C_A C_B  C_D  if conserv_exp_takers==1
est store interest_cons

logit white C_A C_B  C_D  if conserv_exp_takers==1
est store white_cons
logit conservative C_A C_B  C_D  if conserv_exp_takers==1

coefplot gender_cons, bylabel(Female) ||age_cons, bylabel (Age)|| educ_cons, bylabel (Education)|| strength_cons, bylabel (PID strength)||leftright_cons, bylabel (Left-Right)||environ_cons, bylabel (Environment)||immig_cons, bylabel (Immigration)||income_cons, bylabel (Income)||know_cons, bylabel (Knowledge)||media_cons, bylabel (Media Attention)||interest_cons, bylabel (Pol Interest)|| white_cons, bylabel (Race)||, drop(_cons) xline(0)

*Figure OA.2.2.3: Labour Party Supporters

reg q10_gender L_A L_B  L_D  if labour_exp_takers==1
est store gender_lab
reg age  L_A L_B  L_D  if labour_exp_takers==1
est store age_lab
reg age_educ_completed L_A L_B  L_D  if labour_exp_takers==1
est store educ_lab
reg q3_strength_pid L_A L_B  L_D  if labour_exp_takers==1
est store strength_lab
reg q4_leftright L_A L_B  L_D  if labour_exp_takers==1
est store leftright_lab
reg q5_environment L_A L_B  L_D  if labour_exp_takers==1
est store environ_lab
reg q6_immigration L_A L_B  L_D  if labour_exp_takers==1
est store immig_lab
reg q7_domestic_security L_A L_B  L_D  if labour_exp_takers==1
reg q12_income L_A L_B  L_D  if labour_exp_takers==1
est store income_lab
reg allknowledge L_A L_B  L_D  if labour_exp_takers==1
est store know_lab
reg knowledge L_A L_B  L_D  if labour_exp_takers==1
reg media_attention L_A L_B  L_D  if labour_exp_takers==1
est store media_lab
reg TV_  L_A L_B  L_D  if labour_exp_takers==1
reg Newsp  L_A L_B  L_D  if labour_exp_takers==1
reg Radio  L_A L_B  L_D  if labour_exp_takers==1
reg Internet  L_A L_B  L_D  if labour_exp_takers==1
reg other_people L_A L_B  L_D  if labour_exp_takers==1
reg q15_political_interest L_A L_B  L_D   if labour_exp_takers==1
est store interest_lab
logit white L_A L_B  L_D  if labour_exp_takers==1 
est store white_lab
logit conservative L_A L_B  L_D if labour_exp_takers==1 
coefplot gender_lab, bylabel(Female) ||age_lab, bylabel (Age)|| educ_lab, bylabel (Education)|| strength_lab, bylabel (PID strength)||leftright_lab, bylabel (Left-Right)||environ_lab, bylabel (Environment)||immig_lab, bylabel (Immigration)||income_lab, bylabel (Income)||know_lab, bylabel (Knowledge)||media_lab, bylabel (Media Attention)||interest_lab, bylabel (Pol Interest)|| white_lab, bylabel (Race)||, drop(_cons) xline(0)



** Full Results *****

* Figure 1 & Table OA.3.1.1: The effects of message distortion on perceptions: all respondents


reg env_cons_position C_B if cons_env==1 & C_C==0
est store env_con
reg imm_cons_position C_E if con_imm==1 & C_F==0
est store imm_con
reg env_lab_position L_B if lab_env==1 & L_C==0
est store env_lab
reg imm_lab_position L_E if lab_imm==1 & L_F==0
est store imm_lab

coefplot (env_con, label(Conservative Environment) offset(-0.05)) (imm_con, label(Conservative Immigration)) (env_lab, label(Labour Environment)) (imm_lab, label(Labour Immigration)), drop(_cons) xline(0) legend(off) xtitle(Treatment Coefficient)



* Table OA.3.1.2a: The effects of message distortion on perceptions by partisanship: Conservative Party

reg env_cons_position C_B if cons_env==1 & conservative==1 & C_C==0
est store env_cons_cons
reg env_cons_position C_B if cons_env==1 & labour==1 & C_C==0
est store env_cons_lab
reg env_cons_position C_B if cons_env==1 & conservative!=1 & labour!=1 & C_C==0
est store env_cons_allothers

* the following two models are presented on Figure 1 but not on Table OA.3.1.2a
reg env_cons_position C_B if cons_env==1 & independent==1 & C_C==0
est store env_cons_independent
reg env_cons_position C_B if cons_env==1 & third_party==1 & C_C==0
est store env_cons_thirdparty

reg imm_cons_position C_E if con_imm==1 & conservative==1  & C_F==0
est store imm_cons_cons
reg imm_cons_position C_E if con_imm==1 & labour==1 & C_F==0
est store imm_cons_lab
reg imm_cons_position C_E if con_imm==1 & conservative!=1 & labour!=1 & C_F==0
est store imm_cons_allothers

* the following two models are presented on Figure 1 but not on Table OA.3.1.2a
reg imm_cons_position C_E if con_imm==1 & independent==1 & C_F==0
est store imm_cons_independent
reg imm_cons_position C_E if con_imm==1 & third_party==1 & C_F==0
est store imm_cons_thirdparty


* Table OA.3.1.2b: The effects of message distortion on perceptions by partisanship: Labour Party

reg env_lab_position L_B if lab_env==1 & labour==1 & L_C==0
est store env_lab_lab
reg env_lab_position L_B if lab_env==1 & conservative==1 & L_C==0
est store env_lab_cons
reg env_lab_position L_B if lab_env==1 & labour!=1 & conservative!=1 & L_C==0
est store env_lab_allothers

* the following two models are presented on Figure 1 but not on Table OA.3.1.2b
reg env_lab_position L_B if lab_env==1 & independent==1 & L_C==0
est store env_lab_independent
reg env_lab_position L_B if lab_env==1 & third_party==1& L_C==0
est store env_lab_thirdparty


reg imm_lab_position L_E if lab_imm==1 & labour==1 & L_F==0
est store imm_lab_lab
reg imm_lab_position L_E if lab_imm==1 & conservative==1 & L_F==0
est store imm_lab_cons
reg imm_lab_position L_E if lab_imm==1 & labour!=1 & conservative!=1 & L_F==0
est store imm_lab_allothers

* the following two models are presented on Figure 1 but not on Table OA.3.1.2b
reg imm_lab_position L_E if lab_imm==1 & independent==1 & L_F==0
est store imm_lab_independent
reg imm_lab_position L_E if lab_imm==1 & third_party & L_F==0
est store imm_lab_thirdparty

* Figure 2 using the coefficients from the models above

coefplot (env_cons_cons, offset(0.30) pstyle(p3)) (env_cons_lab, offset(0.15)) env_cons_allothers (imm_cons_cons, offset(0.30)) (imm_cons_lab, offset(0.15)) imm_cons_allothers (env_lab_lab, offset(0.30)) (env_lab_cons, offset(0.15)) env_lab_allothers (imm_lab_lab, offset(0.30)) (imm_lab_cons, offset(0.15)) imm_lab_allothers , drop(_cons) xline(0) xtitle(Treatment Coefficient)



* OA.3.2: Means and standard deviations of perceptions

sum env_cons_position if cons_env==1 & C_A==1
sum env_cons_position if cons_env==1 & C_B==1
sum env_cons_position if cons_env==1 & C_C==1

sum imm_cons_position if con_imm==1 & C_D==1
sum imm_cons_position if con_imm==1 & C_E==1
sum imm_cons_position if con_imm==1 & C_F==1

sum env_lab_position if lab_env==1 & L_A==1
sum env_lab_position if lab_env==1 & L_B==1
sum env_lab_position if lab_env==1 & L_C==1

sum imm_lab_position if lab_imm==1 & L_D==1
sum imm_lab_position if lab_imm==1 & L_E==1
sum imm_lab_position if lab_imm==1 & L_F==1

sum env_cons_position if cons_env==1 & C_A==1 & conservative==1
sum env_cons_position if cons_env==1 & C_B==1 & conservative==1
sum env_cons_position if cons_env==1 & C_C==1 & conservative==1
sum imm_cons_position if con_imm==1 & C_D==1 & conservative==1
sum imm_cons_position if con_imm==1 & C_E==1 & conservative==1
sum imm_cons_position if con_imm==1 & C_F==1 & conservative==1
sum env_lab_position if lab_env==1 & L_A==1 & labour==1
sum env_lab_position if lab_env==1 & L_B==1 & labour==1
sum env_lab_position if lab_env==1 & L_C==1 & labour==1
sum imm_lab_position if lab_imm==1 & L_D==1 & labour==1
sum imm_lab_position if lab_imm==1 & L_E==1 & labour==1
sum imm_lab_position if lab_imm==1 & L_F==1 & labour==1

sum env_cons_position if cons_env==1 & C_A==1 & labour==1
sum env_cons_position if cons_env==1 & C_B==1 & labour==1
sum env_cons_position if cons_env==1 & C_C==1 & labour==1
sum imm_cons_position if con_imm==1 & C_D==1 & labour==1
sum imm_cons_position if con_imm==1 & C_E==1 & labour==1
sum imm_cons_position if con_imm==1 & C_F==1 & labour==1
sum env_lab_position if lab_env==1 & L_A==1 & conservative==1
sum env_lab_position if lab_env==1 & L_B==1 & conservative==1
sum env_lab_position if lab_env==1 & L_C==1 & conservative==1
sum imm_lab_position if lab_imm==1 & L_D==1 & conservative==1
sum imm_lab_position if lab_imm==1 & L_E==1 & conservative==1
sum imm_lab_position if lab_imm==1 & L_F==1 & conservative==1

sum env_cons_position if cons_env==1 & C_A==1 & conservative!=1 & labour!=1
sum env_cons_position if cons_env==1 & C_B==1 & conservative!=1 & labour!=1
sum env_cons_position if cons_env==1 & C_C==1 & conservative!=1 & labour!=1
sum imm_cons_position if con_imm==1 & C_D==1 & conservative!=1 & labour!=1
sum imm_cons_position if con_imm==1 & C_E==1 & conservative!=1 & labour!=1
sum imm_cons_position if con_imm==1 & C_F==1 & conservative!=1 & labour!=1
sum env_lab_position if lab_env==1 & L_A==1 & conservative!=1 & labour!=1
sum env_lab_position if lab_env==1 & L_B==1 & conservative!=1 & labour!=1
sum env_lab_position if lab_env==1 & L_C==1 & conservative!=1 & labour!=1
sum imm_lab_position if lab_imm==1 & L_D==1 & conservative!=1 & labour!=1
sum imm_lab_position if lab_imm==1 & L_E==1 & conservative!=1 & labour!=1
sum imm_lab_position if lab_imm==1 & L_F==1 & conservative!=1 & labour!=1


* OA.3.3: Comparisons to the baseline group


* perceptions for all respondents-- comparing control and treatment to baseline (baseline being reference)

reg env_cons_position C_B C_A if cons_env==1
reg imm_cons_position C_E C_D if con_imm==1
reg env_lab_position L_B L_A if lab_env==1
reg imm_lab_position L_E L_D if lab_imm==1


**  OA.3.4: Robustness tests  ***

* OA.3.4.1: Main results with covariates included

* controlling for all control variables

reg env_cons_position C_B q10_gender age white age_educ_compl q4_leftright q5_environment_self q6_immigration_self q7_domestic_security_self q12_income allknowledge media_attention q15_political_interest if cons_env==1 & C_C==0
reg imm_cons_position C_E q10_gender age white age_educ_compl q4_leftright q5_environment_self q6_immigration_self q7_domestic_security_self q12_income allknowledge media_attention q15_political_interest if con_imm==1 & C_F==0
reg env_lab_position L_B q10_gender age white age_educ_compl q4_leftright q5_environment_self q6_immigration_self q7_domestic_security_self q12_income allknowledge media_attention q15_political_interest if lab_env==1 & L_C==0
reg imm_lab_position L_E q10_gender age white age_educ_compl q4_leftright q5_environment_self q6_immigration_self q7_domestic_security_self q12_income allknowledge media_attention q15_political_interest if lab_imm==1 & L_F==0

* controlling for income, allknowledge, white (significant covariates)

reg env_cons_position C_B age white q12_income allknowledge if cons_env==1 & C_C==0
reg imm_cons_position C_E age white  q12_income allknowledge  if con_imm==1 & C_F==0
reg env_lab_position L_B age white q12_income allknowledge  if lab_env==1 & L_C==0
reg imm_lab_position L_E age white q12_income allknowledge  if lab_imm==1 & L_F==0


* OA.3.4.2: Accounting for the conditioning effects of the strength of partisanship

gen strong_partisan=1 if q3_strength_pid==2 | q3_strength_pid==1
replace strong_partisan=0 if q3_strength_pid==0

reg env_cons_position i.C_B##i.strong_partisan if cons_env==1 & conservative==1 & C_C==0
reg env_cons_position i.C_B##i.strong_partisan if cons_env==1 & labour==1 & C_C==0
reg imm_cons_position i.C_E##i.strong_partisan if con_imm==1 & conservative==1  & C_F==0
reg imm_cons_position i.C_E##i.strong_partisan if con_imm==1 & labour==1 & C_F==0

reg env_lab_position i.L_B##i.strong_partisan if lab_env==1 & labour==1 & L_C==0
reg env_lab_position i.L_B##i.strong_partisan if lab_env==1 & conservative==1 & L_C==0
reg imm_lab_position i.L_E##i.strong_partisan if lab_imm==1 & labour==1 & L_F==0
reg imm_lab_position i.L_E##i.strong_partisan if lab_imm==1 & conservative==1 & L_F==0


* OA.3.4.3: Accounting for the conditioning effects of political knowledge

* Table OA.3.4.3a: The effects of message distortion on perceptions by partisanship conditioned by political knowledge: Conservative Party

reg env_cons_position i.C_B##c.allknowledge if cons_env==1 & conservative==1 & C_C==0
reg env_cons_position i.C_B##c.allknowledge if cons_env==1 & labour==1 & C_C==0
reg env_cons_position i.C_B##c.allknowledge if cons_env==1 & conservative!=1 & labour!=1 & C_C==0

reg imm_cons_position i.C_E##c.allknowledge if con_imm==1 & conservative==1  & C_F==0
reg imm_cons_position i.C_E##c.allknowledge if con_imm==1 & labour==1 & C_F==0
reg imm_cons_position i.C_E##c.allknowledge if con_imm==1 & conservative!=1 & labour!=1 & C_F==0

* Table OA.3.4.3b: The effects of message distortion on perceptions by partisanship conditioned by political knowledge: Labour Party

reg env_lab_position i.L_B##c.allknowledge if lab_env==1 & labour==1 & L_C==0
reg env_lab_position i.L_B##c.allknowledge if lab_env==1 & conservative==1 & L_C==0
reg env_lab_position i.L_B##c.allknowledge if lab_env==1 & labour!=1 & conservative!=1 & L_C==0

reg imm_lab_position i.L_E##c.allknowledge if lab_imm==1 & labour==1 & L_F==0
reg imm_lab_position i.L_E##c.allknowledge if lab_imm==1 & conservative==1 & L_F==0
reg imm_lab_position i.L_E##c.allknowledge if lab_imm==1 & labour!=1 & conservative!=1 & L_F==0




* OA.3.4.4: Comparing our sample to BNES and rerunning the models with the weighted sample*


use bes_rps_2019_1.0.0.dta, clear

svyset _n [pweight= wt_vote]

* age

replace Age=. if Age<18
sum Age, detail

gen age_cat= "young" if Age<35 & Age>17
replace age_cat="middle" if Age>35 & Age<56
replace age_cat="old" if Age>55 & Age<100
tab age_cat
svy: tab age_cat

*gender

tab y09 
svy: tab y09

* pid
tab d01
svy: tab d01

gen labour= 1 if d01==1
replace labour=0 if d01==2
svy: tab labour

gen pid=1 if d01==1
replace pid=2 if d01==2
replace pid=3 if d01==0
replace pid=4 if d01>2
tab pid
svy: tab pid

* political interest

tab a03
svy: tab a03

* knowledge

gen know1= 1 if x01_1==1
replace know1=0 if x01_1==2 | x01_1==-1
gen know2=  1 if x01_2==1
replace know2=0 if x01_2==2 | x01_2==-1
gen know3=  1 if x01_3==1
replace know3=0 if x01_3==2 | x01_3==-1
gen know4= 1 if x01_4==1
replace know4=0 if x01_4==2 | x01_4==-1
gen know5= 1 if x01_5==1
replace know5=0 if x01_5==2 | x01_5==-1
gen know6= 1 if x01_6==1
replace know6=0 if x01_6==2 | x01_6==-1
gen knowledge= know1 + know2 + know3 + know4+ know5+ know6 if x01_1!=-999 | x01_2!=-999 | x01_3!=-999 | x01_4!=-999 | x01_5!=-999 | x01_6!=-999
tab knowledge
svy: tab knowledge

gen high_know=1 if knowledge==3 | knowledge==4 | knowledge==5 | knowledge==6
replace high_know=0 if knowledge==1 | knowledge==2  | knowledge==0
tab high_know
sum high_know
svy: tab high_know
svy: mean high_know

* education

gen education_comp = "23-above" if education==1
replace education_comp= "22-23" if education==2
replace education_comp= "19-21" if education==3 | education==4 | education==5 | education==6
replace education_comp= "17-19" if education==7 | education==8 | education==9
replace education_comp= "15-16" if education==10 | education==11
replace education_comp= "rest_diverse" if education>11 
tab education_comp
gen high_educ=1 if education_comp == "23-above"  | education_comp == "22-23"
replace high_educ=0 if education>2
tab high_educ
sum high_educ
svy: tab high_educ
svy: mean high_educ


* adjusting our experimental data
use distortion_experiment_data_cleaned.dta, replace

sum age
gen age_cat= 1 if age<35 & age>17
replace age_cat=2 if age>35 & age<56
replace age_cat=3 if age>55 & age<100
tab age_cat

tab q10_gender

tab q2_pid

gen pid= 1 if q2_pid=="Labour Party"
replace pid=2 if q2_pid=="Conservative Party"
replace pid=3 if q2_pid=="None"
replace pid=4 if pid!=1 & pid!=2 & pid!=3 
tab pid

tab allknow
gen high_know=1 if allknow==5 | allknow==4 | allknow==3
replace high_know=0 if allknow==0 | allknow==1 | allknow==2
tab high_know

ipfweight age_cat q10_gender pid high_know, gen(wgt) val(26.8 33.4 39.8 49.09 50.91 33.1 34.32 14.26 18.33 52.36 47.64) maxit(100)

svyset wgt

svy: reg env_cons_position C_B if cons_env==1 & C_C==0
est store env_con_w
svy: reg imm_cons_position C_E if con_imm==1 & C_F==0
est store imm_con_w
svy: reg env_lab_position L_B if lab_env==1 & L_C==0
est store env_lab_w
svy: reg imm_lab_position L_E if lab_imm==1 & L_F==0
est store imm_lab_w

coefplot (env_con_w, label(Conservative Environment) offset(-0.05)) (imm_con_w, label(Conservative Immigration)) (env_lab_w, label(Labour Environment)) (imm_lab_w, label(Labour Immigration)), drop(_cons) xline(0) legend(off) xtitle(Treatment Coefficient)


* OA.3.4.5: Robustness of the results when we control for respondent certainty

reg env_cons_position C_B env_cons_certainty if cons_env==1 & C_C==0
est store env_con_withcert
reg imm_cons_position C_E imm_cons_certainty if con_imm==1 & C_F==0
est store imm_con_withcert
reg env_lab_position L_B env_lab_certainty if lab_env==1 & L_C==0
est store env_lab_withcert
reg imm_lab_position L_E imm_lab_certainty   if lab_imm==1 & L_F==0
est store imm_lab_withcert

coefplot (env_con_withcert, label(Conservative Environment) offset(-0.05)) (imm_con_withcert, label(Conservative Immigration)) (env_lab_withcert, label(Labour Environment)) (imm_lab_withcert, label(Labour Immigration)), keep(C_B C_E L_B L_E) drop(_cons) xline(0) legend(off) xtitle(Treatment Coefficient)



